1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Range;
26 
27 private import gobject.ObjectG;
28 private import gobject.Signals;
29 private import gtk.Adjustment;
30 private import gtk.OrientableIF;
31 private import gtk.OrientableT;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 private import std.algorithm;
36 
37 
38 /**
39  * `GtkRange` is the common base class for widgets which visualize an
40  * adjustment.
41  * 
42  * Widgets that are derived from `GtkRange` include
43  * [class@Gtk.Scale] and [class@Gtk.Scrollbar].
44  * 
45  * Apart from signals for monitoring the parameters of the adjustment,
46  * `GtkRange` provides properties and methods for setting a
47  * “fill level” on range widgets. See [method@Gtk.Range.set_fill_level].
48  */
49 public class Range : Widget, OrientableIF
50 {
51 	/** the main Gtk struct */
52 	protected GtkRange* gtkRange;
53 
54 	/** Get the main Gtk struct */
55 	public GtkRange* getRangeStruct(bool transferOwnership = false)
56 	{
57 		if (transferOwnership)
58 			ownedRef = false;
59 		return gtkRange;
60 	}
61 
62 	/** the main Gtk struct as a void* */
63 	protected override void* getStruct()
64 	{
65 		return cast(void*)gtkRange;
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GtkRange* gtkRange, bool ownedRef = false)
72 	{
73 		this.gtkRange = gtkRange;
74 		super(cast(GtkWidget*)gtkRange, ownedRef);
75 	}
76 
77 	// add the Orientable capabilities
78 	mixin OrientableT!(GtkRange);
79 
80 
81 	/** */
82 	public static GType getType()
83 	{
84 		return gtk_range_get_type();
85 	}
86 
87 	/**
88 	 * Get the adjustment which is the “model” object for `GtkRange`.
89 	 *
90 	 * Returns: a `GtkAdjustment`
91 	 */
92 	public Adjustment getAdjustment()
93 	{
94 		auto __p = gtk_range_get_adjustment(gtkRange);
95 
96 		if(__p is null)
97 		{
98 			return null;
99 		}
100 
101 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) __p);
102 	}
103 
104 	/**
105 	 * Gets the current position of the fill level indicator.
106 	 *
107 	 * Returns: The current fill level
108 	 */
109 	public double getFillLevel()
110 	{
111 		return gtk_range_get_fill_level(gtkRange);
112 	}
113 
114 	/**
115 	 * Gets whether the `GtkRange` respects text direction.
116 	 *
117 	 * See [method@Gtk.Range.set_flippable].
118 	 *
119 	 * Returns: %TRUE if the range is flippable
120 	 */
121 	public bool getFlippable()
122 	{
123 		return gtk_range_get_flippable(gtkRange) != 0;
124 	}
125 
126 	/**
127 	 * Gets whether the range is inverted.
128 	 *
129 	 * See [method@Gtk.Range.set_inverted].
130 	 *
131 	 * Returns: %TRUE if the range is inverted
132 	 */
133 	public bool getInverted()
134 	{
135 		return gtk_range_get_inverted(gtkRange) != 0;
136 	}
137 
138 	/**
139 	 * This function returns the area that contains the range’s trough,
140 	 * in coordinates relative to @range's origin.
141 	 *
142 	 * This function is useful mainly for `GtkRange` subclasses.
143 	 *
144 	 * Params:
145 	 *     rangeRect = return location for the range rectangle
146 	 */
147 	public void getRangeRect(out GdkRectangle rangeRect)
148 	{
149 		gtk_range_get_range_rect(gtkRange, &rangeRect);
150 	}
151 
152 	/**
153 	 * Gets whether the range is restricted to the fill level.
154 	 *
155 	 * Returns: %TRUE if @range is restricted to the fill level.
156 	 */
157 	public bool getRestrictToFillLevel()
158 	{
159 		return gtk_range_get_restrict_to_fill_level(gtkRange) != 0;
160 	}
161 
162 	/**
163 	 * Gets the number of digits to round the value to when
164 	 * it changes.
165 	 *
166 	 * See [signal@Gtk.Range::change-value].
167 	 *
168 	 * Returns: the number of digits to round to
169 	 */
170 	public int getRoundDigits()
171 	{
172 		return gtk_range_get_round_digits(gtkRange);
173 	}
174 
175 	/**
176 	 * Gets whether the range displays the fill level graphically.
177 	 *
178 	 * Returns: %TRUE if @range shows the fill level.
179 	 */
180 	public bool getShowFillLevel()
181 	{
182 		return gtk_range_get_show_fill_level(gtkRange) != 0;
183 	}
184 
185 	/**
186 	 * This function returns sliders range along the long dimension,
187 	 * in widget->window coordinates.
188 	 *
189 	 * This function is useful mainly for `GtkRange` subclasses.
190 	 *
191 	 * Params:
192 	 *     sliderStart = return location for the slider's start
193 	 *     sliderEnd = return location for the slider's end
194 	 */
195 	public void getSliderRange(out int sliderStart, out int sliderEnd)
196 	{
197 		gtk_range_get_slider_range(gtkRange, &sliderStart, &sliderEnd);
198 	}
199 
200 	/**
201 	 * This function is useful mainly for `GtkRange` subclasses.
202 	 *
203 	 * See [method@Gtk.Range.set_slider_size_fixed].
204 	 *
205 	 * Returns: whether the range’s slider has a fixed size.
206 	 */
207 	public bool getSliderSizeFixed()
208 	{
209 		return gtk_range_get_slider_size_fixed(gtkRange) != 0;
210 	}
211 
212 	/**
213 	 * Gets the current value of the range.
214 	 *
215 	 * Returns: current value of the range.
216 	 */
217 	public double getValue()
218 	{
219 		return gtk_range_get_value(gtkRange);
220 	}
221 
222 	/**
223 	 * Sets the adjustment to be used as the “model” object for the `GtkRange`
224 	 *
225 	 * The adjustment indicates the current range value, the minimum and
226 	 * maximum range values, the step/page increments used for keybindings
227 	 * and scrolling, and the page size.
228 	 *
229 	 * The page size is normally 0 for `GtkScale` and nonzero for `GtkScrollbar`,
230 	 * and indicates the size of the visible area of the widget being scrolled.
231 	 * The page size affects the size of the scrollbar slider.
232 	 *
233 	 * Params:
234 	 *     adjustment = a `GtkAdjustment`
235 	 */
236 	public void setAdjustment(Adjustment adjustment)
237 	{
238 		gtk_range_set_adjustment(gtkRange, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
239 	}
240 
241 	/**
242 	 * Set the new position of the fill level indicator.
243 	 *
244 	 * The “fill level” is probably best described by its most prominent
245 	 * use case, which is an indicator for the amount of pre-buffering in
246 	 * a streaming media player. In that use case, the value of the range
247 	 * would indicate the current play position, and the fill level would
248 	 * be the position up to which the file/stream has been downloaded.
249 	 *
250 	 * This amount of prebuffering can be displayed on the range’s trough
251 	 * and is themeable separately from the trough. To enable fill level
252 	 * display, use [method@Gtk.Range.set_show_fill_level]. The range defaults
253 	 * to not showing the fill level.
254 	 *
255 	 * Additionally, it’s possible to restrict the range’s slider position
256 	 * to values which are smaller than the fill level. This is controlled
257 	 * by [method@Gtk.Range.set_restrict_to_fill_level] and is by default
258 	 * enabled.
259 	 *
260 	 * Params:
261 	 *     fillLevel = the new position of the fill level indicator
262 	 */
263 	public void setFillLevel(double fillLevel)
264 	{
265 		gtk_range_set_fill_level(gtkRange, fillLevel);
266 	}
267 
268 	/**
269 	 * Sets whether the `GtkRange` respects text direction.
270 	 *
271 	 * If a range is flippable, it will switch its direction
272 	 * if it is horizontal and its direction is %GTK_TEXT_DIR_RTL.
273 	 *
274 	 * See [method@Gtk.Widget.get_direction].
275 	 *
276 	 * Params:
277 	 *     flippable = %TRUE to make the range flippable
278 	 */
279 	public void setFlippable(bool flippable)
280 	{
281 		gtk_range_set_flippable(gtkRange, flippable);
282 	}
283 
284 	/**
285 	 * Sets the step and page sizes for the range.
286 	 *
287 	 * The step size is used when the user clicks the `GtkScrollbar`
288 	 * arrows or moves a `GtkScale` via arrow keys. The page size
289 	 * is used for example when moving via Page Up or Page Down keys.
290 	 *
291 	 * Params:
292 	 *     step = step size
293 	 *     page = page size
294 	 */
295 	public void setIncrements(double step, double page)
296 	{
297 		gtk_range_set_increments(gtkRange, step, page);
298 	}
299 
300 	/**
301 	 * Sets whether to invert the range.
302 	 *
303 	 * Ranges normally move from lower to higher values as the
304 	 * slider moves from top to bottom or left to right. Inverted
305 	 * ranges have higher values at the top or on the right rather
306 	 * than on the bottom or left.
307 	 *
308 	 * Params:
309 	 *     setting = %TRUE to invert the range
310 	 */
311 	public void setInverted(bool setting)
312 	{
313 		gtk_range_set_inverted(gtkRange, setting);
314 	}
315 
316 	/**
317 	 * Sets the allowable values in the `GtkRange`.
318 	 *
319 	 * The range value is clamped to be between @min and @max.
320 	 * (If the range has a non-zero page size, it is clamped
321 	 * between @min and @max - page-size.)
322 	 *
323 	 * Params:
324 	 *     min = minimum range value
325 	 *     max = maximum range value
326 	 */
327 	public void setRange(double min, double max)
328 	{
329 		gtk_range_set_range(gtkRange, min, max);
330 	}
331 
332 	/**
333 	 * Sets whether the slider is restricted to the fill level.
334 	 *
335 	 * See [method@Gtk.Range.set_fill_level] for a general description
336 	 * of the fill level concept.
337 	 *
338 	 * Params:
339 	 *     restrictToFillLevel = Whether the fill level restricts slider movement.
340 	 */
341 	public void setRestrictToFillLevel(bool restrictToFillLevel)
342 	{
343 		gtk_range_set_restrict_to_fill_level(gtkRange, restrictToFillLevel);
344 	}
345 
346 	/**
347 	 * Sets the number of digits to round the value to when
348 	 * it changes.
349 	 *
350 	 * See [signal@Gtk.Range::change-value].
351 	 *
352 	 * Params:
353 	 *     roundDigits = the precision in digits, or -1
354 	 */
355 	public void setRoundDigits(int roundDigits)
356 	{
357 		gtk_range_set_round_digits(gtkRange, roundDigits);
358 	}
359 
360 	/**
361 	 * Sets whether a graphical fill level is show on the trough.
362 	 *
363 	 * See [method@Gtk.Range.set_fill_level] for a general description
364 	 * of the fill level concept.
365 	 *
366 	 * Params:
367 	 *     showFillLevel = Whether a fill level indicator graphics is shown.
368 	 */
369 	public void setShowFillLevel(bool showFillLevel)
370 	{
371 		gtk_range_set_show_fill_level(gtkRange, showFillLevel);
372 	}
373 
374 	/**
375 	 * Sets whether the range’s slider has a fixed size, or a size that
376 	 * depends on its adjustment’s page size.
377 	 *
378 	 * This function is useful mainly for `GtkRange` subclasses.
379 	 *
380 	 * Params:
381 	 *     sizeFixed = %TRUE to make the slider size constant
382 	 */
383 	public void setSliderSizeFixed(bool sizeFixed)
384 	{
385 		gtk_range_set_slider_size_fixed(gtkRange, sizeFixed);
386 	}
387 
388 	/**
389 	 * Sets the current value of the range.
390 	 *
391 	 * If the value is outside the minimum or maximum range values,
392 	 * it will be clamped to fit inside them. The range emits the
393 	 * [signal@Gtk.Range::value-changed] signal if the value changes.
394 	 *
395 	 * Params:
396 	 *     value = new value of the range
397 	 */
398 	public void setValue(double value)
399 	{
400 		gtk_range_set_value(gtkRange, value);
401 	}
402 
403 	/**
404 	 * Emitted before clamping a value, to give the application a
405 	 * chance to adjust the bounds.
406 	 *
407 	 * Params:
408 	 *     value = the value before we clamp
409 	 */
410 	gulong addOnAdjustBounds(void delegate(double, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
411 	{
412 		return Signals.connect(this, "adjust-bounds", dlg, connectFlags ^ ConnectFlags.SWAPPED);
413 	}
414 
415 	/**
416 	 * Emitted when a scroll action is performed on a range.
417 	 *
418 	 * It allows an application to determine the type of scroll event
419 	 * that occurred and the resultant new value. The application can
420 	 * handle the event itself and return %TRUE to prevent further
421 	 * processing. Or, by returning %FALSE, it can pass the event to
422 	 * other handlers until the default GTK handler is reached.
423 	 *
424 	 * The value parameter is unrounded. An application that overrides
425 	 * the ::change-value signal is responsible for clamping the value
426 	 * to the desired number of decimal digits; the default GTK
427 	 * handler clamps the value based on [property@Gtk.Range:round-digits].
428 	 *
429 	 * Params:
430 	 *     scroll = the type of scroll action that was performed
431 	 *     value = the new value resulting from the scroll action
432 	 *
433 	 * Returns: %TRUE to prevent other handlers from being invoked for
434 	 *     the signal, %FALSE to propagate the signal further
435 	 */
436 	gulong addOnChangeValue(bool delegate(GtkScrollType, double, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
437 	{
438 		return Signals.connect(this, "change-value", dlg, connectFlags ^ ConnectFlags.SWAPPED);
439 	}
440 
441 	/**
442 	 * Virtual function that moves the slider.
443 	 *
444 	 * Used for keybindings.
445 	 *
446 	 * Params:
447 	 *     step = how to move the slider
448 	 */
449 	gulong addOnMoveSlider(void delegate(GtkScrollType, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
450 	{
451 		return Signals.connect(this, "move-slider", dlg, connectFlags ^ ConnectFlags.SWAPPED);
452 	}
453 
454 	/**
455 	 * Emitted when the range value changes.
456 	 */
457 	gulong addOnValueChanged(void delegate(Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
458 	{
459 		return Signals.connect(this, "value-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
460 	}
461 }